package main

import (
	"fmt"
	"io/ioutil"
	"path/filepath"
)

func main() {
	list := make([]string, 0, 5)
	findFiles("C:\\Users\\smile\\projects\\GoProjects\\src\\go-core\\chapter5\\", &list)
	for _, v := range list {
		fmt.Println(v)
	}
}

func findFiles(filePath string, list *[]string) {
	dir, err := ioutil.ReadDir(filePath)
	if err != nil {
		panic(err)
	}
	for _, v := range dir {
		if v.IsDir() {
			fullName := filepath.Join(filePath, v.Name())
			findFiles(fullName, list)
		}
		*list = append(*list, v.Name())
	}
}
